#include<iostream>
#include<omp.h>
#include<stdio.h>
#include<cstdlib>
#include<sys/time.h>

using namespace std;

int main(int argc,char *argv[])
{
  int N=2000; 
  int a[N][N] , b[N][N] , c[N][N];
  int i=0 , j=0 , k=0;
  // Setting all entires of matrix A by i*j
  for( i = 0 ; i < N ; i++)
    for( j = 0 ; j < N ; j++){
      a[i][j]=i*j;
      b[i][j]=i+j;
      c[i][j]=0;
    }

timeval tim;
  gettimeofday(&tim, NULL);
  double t1=tim.tv_sec+(tim.tv_usec/1000000.0);
	  
  #pragma omp parallel for  
  for( i = 0 ; i < N ; i++)
#pragma omp parallel for
for( k = 0 ;k < N ; k++)
#pragma omp parallel for   
      for( j = 0 ; j < N ; j++)
 
	    {
	      c[i][j] += a[i][k]*b[k][j];
	      //	      sum = 0;
	      
	      // sum +=;
	      // c[i][j] = sum;
	    }
  gettimeofday(&tim, NULL);
  double t2=tim.tv_sec+(tim.tv_usec/1000000.0);
  printf("%.6lf seconds elapsed\n", t2-t1);
  /*  cout<<"The resultant matrix is:\n";
   for( i = 0 ; i < N ; i++)
    {
      for( j = 0 ; j < N ; j++)
	cout<<c[i][j]<<" ";
      cout<<endl;
    }
  */
  return 0;
}
